/*
 * Timer.cpp
 *
 *  Created on: 06/09/2012
 *      Author: leandro
 */

#include "Timer.h"

Timer::Timer(){
	startTick = 0;
	pauseTick = 0;
	started = false;
	paused = false;
}

void Timer::start(){
	started = true;
	paused = false;
	startTick = SDL_GetTicks();
}

void Timer::stop(){
	started = false;
	paused = false;
}

Uint32 Timer::getTick(){
	if (started == true){
		if (paused == true) return pauseTick;
		else return SDL_GetTicks() - startTick;
	}
	return 0;
}

void Timer::pause(){
	if ((started == true) && (paused == false)){
		paused = true;
		pauseTick = SDL_GetTicks() - started;
	}

}

void Timer::unPause(){
	if (paused == true){
		paused = false;
		startTick = SDL_GetTicks() - pauseTick;
		pauseTick = 0;
	}
}

bool Timer::isStarted(){
	return started;
}

bool Timer::isPaused(){
	return paused;
}

